<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>更新excel</title>
</head>
<script src="{{ url_for('static',filename='js/jquery-2.1.1.min.js') }}"></script>
<body>
    <h1>更新excel</h1>
    <form id="start" action="" enctype='multipart/form-data' method='POST'>
        <input type="submit" value="开始"><br/>
    </form>
</body>
<script>
    checkbox_statue = false
    $(document).ready(function() {
        get_data();
    });

    function get_data() {
            $.ajax({
                url: '/返回excel列表',
                data: {},
                type: 'POST',
                async: false,
                dataType: 'json',
                success: function(data) {
                    show_excel(data['data'])
                },
                error: function(msg) {
                    console.log(msg);
                }
            })
        };

    function show_excel(list){
        list = list.sort()
        var tb = document.getElementById("start"); //获取表格的dom节点
        tb.innerHTML += "<input type=\"checkbox\" onclick=\"all_check()\">" +"全选"+"<br/>"
        for(var i=0; i<list.length; i++){
            tb.innerHTML += "<input type=\"checkbox\" value="+list[i]+" name="+i+">"+list[i]+"<br/>"
        }
        tb.innerHTML += "<input type=\"submit\" value=\"开始\">"
    };

    function all_check(){
        if(checkbox_statue){
            $("input[type='checkbox']").each(function(){this.checked = false})
            checkbox_statue = !checkbox_statue
        }else{
            $("input[type='checkbox']").each(function(){this.checked = true})
            checkbox_statue = !checkbox_statue
        }
    };
</script>
</html>